import {
  WHETHER_OPTION,
  STOCK_ATTR_OPTION,
  DEMAND_TYPE_OPTION,
} from '@sourcing/constants';
export const TAB_LISTS = [
  { title: '全部状态', name: '' },
  { title: '询价中', name: '100' },
  { title: '待订货审批', name: '200' },
  { title: '待生成订单', name: '300' },
  { title: '已完成', name: '400' },
  { title: '询价取消', name: '500' }
]
// 表格操作列 tab对应列宽
export const ACTION_WIDTH_OBJ = {
  '100': 110,
  '200': 100,
  '300': 225,
  '400': 100,
  '500': 100,
}
export const FORM_ITEMS = [
  {
    prop: 'originCode',
    label: '来源单据号',
    type: 'input'
  },
  {
    prop: 'sourceBillNo',
    label: '询价单号',
    type: 'input'
  },
  {
    prop: 'productBrand',
    label: '品牌',
    type: 'input'
  },
  {
    prop: 'skuCode',
    label: '商品代码',
    type: 'input'
  },
  {
    prop: 'purchaseSkuName',
    label: '采购商品名称',
    type: 'input'
  },
  {
    prop: 'purchaseInquirerCompanyName',
    label: '采购订货部门',
    type: 'input'
  },
  {
    prop: 'purchaseInquirerName',
    label: '采购询价人',
    type: 'input'
  },
  {
    prop: 'serviceProviderName',
    label: '指定渠道名称',
    type: 'input'
  },
  {
    prop: 'isProcedures',
    label: '是否走手续',
    type: 'select',
    options: WHETHER_OPTION
  },
  {
    prop: 'isServiceProvider',
    label: '是否服务商',
    type: 'select',
    options: WHETHER_OPTION
  },
  {
    prop: 'stockAttr',
    label: '存量属性',
    type: 'select',
    options: STOCK_ATTR_OPTION
  },
  {
    prop: 'demandType',
    label: '需求类型',
    type: 'select',
    selectData: DEMAND_TYPE_OPTION
  },
  {
    prop: 'categoryCode',
    label: '分类',
    type: 'category'
  },
]

// 采购询价 ----客户订货 列表字段
export const getTableColumns = (parent) => {
  return [
    {
      prop: 'creationDate',
      label: '制单时间',
      width: 140
    },
    {
      prop: 'reqArrivalDate',
      label: '要求到货时间',
      width: 140
    },
    {
      prop: 'billStatusName',
      label: '询价状态',
      width: 90
    },
    {
      prop: 'approvalStatusStr',
      label: '商品准入状态',
      width: 100,
      isPending: true, // 待定货审批
      render: (h, { row }) => {
        // 0-无需审批，100-待审批，200-审批驳回，300-审批通过
        if (row.approvalStatus == 100) {
          return <el-link onClick={() => parent.handleViewAuditDetail(row)} type="primary">{row.approvalStatusStr}</el-link>
        }
        return <span>{row.approvalStatusStr}</span>
      }
    },
    {
      prop: 'rejectReason',
      label: '驳回原因',
      width: 90,
      isPending: true,
    },
    {
      prop: 'rejectRemark',
      label: '驳回备注',
      width: 90,
      isPending: true,
    },
    {
      prop: 'originCode',
      label: '来源单据号',
      width: 140
    },
    {
      prop: 'sourceBillNo',
      label: '询价单号',
      width: 140
    },
    {
      prop: 'purchaseInquirerCompanyName',
      label: '采购订货部门',
      width: 100
    },
    {
      prop: 'saleCompanyName',
      label: '销售公司',
    },
    {
      prop: 'receiveCompanyName',
      label: '收货公司',
    },
    {
      prop: 'isProceduresStr',
      label: '是否走手续',
      width: 100
    },
    {
      prop: 'isServiceProviderStr',
      label: '是否服务商',
      width: 100
    },
    {
      prop: 'serviceProviderName',
      label: '指定渠道名称',
      width: 120
    },
    {
      prop: 'isScenePickupStr',
      label: '是否现场接货',
      width: 120
    },
    {
      prop: 'isDirectContactStr',
      label: '能否直接联系客户',
      width: 120
    },
    {
      prop: 'mark',
      label: '备注',
    },
    {
      prop: 'sourcingBillId',
      label: '合同查看',
      render: (h, { row }) => {
        if (row.billStatus == 200 || row.billStatus == 300 || row.billStatus == 400) {
          return <el-link onClick={() => parent.queryContractInfoAction(row)} type="primary">查看</el-link>
        }
      }
    },
    {
      prop: 'creatorName',
      label: '上游制单人',
      width: 90
    },
    {
      prop: 'purchaseInquirerName',
      label: '采购订货人',
      width: 90
    },
    {
      prop: 'deliveryAddress',
      label: '送货地址',
    },
    {
      prop: 'stockAttrStr',
      label: '存量属性',
    },
    {
      prop: 'skuTypeStr',
      label: '商品类型',
    },
    {
      prop: 'skuCode',
      label: '商品代码',
    },
    {
      prop: 'skuName',
      label: '商品名称',
    },
    {
      prop: 'categoryCode',
      label: '分类代码',
    },
    {
      prop: 'categoryName',
      label: '分类名称',
    },
    {
      prop: 'productBrand',
      label: '品牌',
    },
    {
      prop: 'productSpec',
      label: '商品规格',
    },
    {
      prop: 'unit',
      label: '计量单位',
    },
    {
      prop: 'amount',
      label: '数量',
    },
    {
      prop: 'sellMark',
      label: '销售备注',
    },
    {
      prop: 'reqQualification',
      label: '资质要求',
    },
    {
      prop: 'fileGroupId',
      label: '附件',
      render: (h, { row }) => {
        if (row.fileGroupId && row.fileGroupId != '0') {
          return <el-link onClick={() => parent.handleViewFileList(row)} type="primary">查看附件</el-link>
        }
      }
    },
    {
      prop: 'emergencyOrderStr',
      label: '是否紧急订货',
      width: 110
    },
  ]
}
// 待生成订单列表字段
export const getTableColumnsForGenerate = (parent) => {
  return [
    {
      prop: 'creationDate',
      label: '制单时间',
      width: 140
    },
    {
      prop: 'reqArrivalDate',
      label: '要求到货时间',
      width: 140
    },
    {
      prop: 'billStatusName',
      label: '询价状态',
      width: 90
    },
    // goodsHandleModeStatus 1-无需确认，2待确认，3-同意，4-不同意
    {
      prop: 'goodsHandleModeStatusStr',
      label: '待确认货物处理方式状态',
      width: 160,
    },
    // 1-无需二次定价，2-待二次定价，3-已完成二次定价
    {
      prop: 'secondPriceStatusStr',
      label: '二次定价状态',
      width: 100,
    },
    {
      prop: 'supplierCode',
      label: '中标供应商代码',
      width: 120,
    },
    {
      prop: 'supplierName',
      label: '中标供应商名称',
      width: 120,
    },
    {
      prop: 'originCode',
      label: '来源单据号',
      width: 140
    },
    {
      prop: 'sourceBillNo',
      label: '询价单号',
      width: 140
    },
    {
      prop: 'purchaseInquirerCompanyName',
      label: '采购订货部门',
      width: 100
    },
    {
      prop: 'saleCompanyName',
      label: '销售公司',
    },
    {
      prop: 'receiveCompanyName',
      label: '收货公司',
    },
    {
      prop: 'isProceduresStr',
      label: '是否走手续',
      width: 100
    },
    {
      prop: 'isServiceProviderStr',
      label: '是否服务商',
      width: 100
    },
    {
      prop: 'serviceProviderName',
      label: '指定渠道名称',
      width: 120
    },
    {
      prop: 'isScenePickupStr',
      label: '是否现场接货',
      width: 120
    },
    {
      prop: 'isDirectContactStr',
      label: '能否直接联系客户',
      width: 120
    },
    {
      prop: 'mark',
      label: '备注',
    },
    {
      prop: 'sourcingBillId',
      label: '合同查看',
      render: (h, { row }) => {
        if (row.billStatus == 200 || row.billStatus == 300 || row.billStatus == 400) {
          return <el-link onClick={() => parent.queryContractInfoAction(row)} type="primary">查看</el-link>
        }
      }
    },
    {
      prop: 'creatorName',
      label: '上游制单人',
      width: 90
    },
    {
      prop: 'purchaseInquirerName',
      label: '采购订货人',
      width: 90
    },
    {
      prop: 'deliveryAddress',
      label: '送货地址',
    },
    {
      prop: 'stockAttrStr',
      label: '存量属性',
    },
    {
      prop: 'skuTypeStr',
      label: '商品类型',
    },
    {
      prop: 'skuCode',
      label: '商品代码',
    },
    {
      prop: 'skuName',
      label: '商品名称',
    },
    {
      prop: 'categoryCode',
      label: '分类代码',
    },
    {
      prop: 'categoryName',
      label: '分类名称',
    },
    {
      prop: 'productBrand',
      label: '品牌',
    },
    {
      prop: 'productSpec',
      label: '商品规格',
    },
    {
      prop: 'unit',
      label: '计量单位',
    },
    {
      prop: 'amount',
      label: '数量',
    },
    {
      prop: 'sellMark',
      label: '销售备注',
    },
    {
      prop: 'reqQualification',
      label: '资质要求',
    },
    {
      prop: 'fileGroupId',
      label: '附件',
      render: (h, { row }) => {
        if (row.fileGroupId && row.fileGroupId != '0') {
          return <el-link onClick={() => parent.handleViewFileList(row)} type="primary">查看附件</el-link>
        }
      }
    },
    {
      prop: 'emergencyOrderStr',
      label: '是否紧急订货',
      width: 110
    },
  ]
}
